package net.jiabing.online_class.controller;


import net.jiabing.online_class.model.entity.Video;
import net.jiabing.online_class.model.entity.VideoBanner;
import net.jiabing.online_class.service.VideoService;
import net.jiabing.online_class.utils.BaseCache;
import net.jiabing.online_class.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

// localhost:8080/list
@RestController
@RequestMapping("api/v1/pub/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    /*
    轮播图列表
     */
    @GetMapping("list_banner")
    private JsonData indexBanner(){
        List<VideoBanner>  bannerList = videoService.listBanner();

//        int i = 1 / 0;
        return JsonData.buildSuccess(bannerList);
    }

    @RequestMapping("list")
    public Object listVideo(){
        List<Video> videoList = videoService.listVideo();
        System.out.println(111222);
        return JsonData.buildSuccess(videoList);
    }


    /*
    查询视频详情，包含章，集信息
     */
    @GetMapping("find_detail_by_id")
    public JsonData findDetailById(@RequestParam(value = "video_id",required = true) int videoId){
        Video video = videoService.findDetailById(videoId);

        return JsonData.buildSuccess(video);
    }

}
